﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using CapaEntidades;

namespace CapaDatos
{
    public class daComisionPersonal
    {
        public static List<enComisionPersonal> getComisionPersonalAll()
        {
            SqlConnection cn = null;
            SqlCommand cmd = null;
            SqlDataReader dr = null;
            List<enComisionPersonal> lstComision = null;
            try
            {

                cn = Conexion.getConexion();
                cmd = new SqlCommand("wsp_comisionpersonal", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                dr = cmd.ExecuteReader();
                lstComision = new List<enComisionPersonal>();
                while (dr.Read())
                {

                    enComisionPersonal comision = new enComisionPersonal();
                    comision.idPersonal = Convert.ToInt32(dr[0].ToString());
                    comision.fecha = dr[1].ToString();
                    comision.comision = Convert.ToDouble(dr[2].ToString());                   
                    lstComision.Add(comision);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                dr.Close();
                cn.Close();
            }
            return lstComision;
        }
    }
}
